<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    function formatMoney(str) {
        if (typeof str != 'string') {
            str = str + ''
        }
        if (str === '' || str === undefined) {
            return str
        }
        if (str === '0') {
            return '0.00'
        }
        if (str.indexOf('.') === 0) {
            // eslint-disable-next-line no-param-reassign
            str = `0${str}`
        }
        if (str.substr(-1) === '.') {
            // eslint-disable-next-line no-param-reassign
            str += '00'
        }
        // console.log('处理到这')
        // eslint-disable-next-line no-param-reassign
        str =
            str.indexOf('.') >= 0
                ? str.replace(/\.\d*/i, xiaoshu => {
                      return xiaoshu.length === 2 ? `${xiaoshu}0` : xiaoshu.slice(0, 3)
                  })
                : `${str}.00`
        const intNum = str.substring(0, str.indexOf('.')).replace(/\B(?=(?:\d{3})+$)/g, ',')
        const dot = str.substring(str.indexOf('.'), str.length)
        return intNum + dot
    }
    console.log(typeof formatMoney('11000000'))
    </script>
</body>
</html>